﻿using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System;

namespace WordSmith_V1.Library.Model
{
    public class User
    {
        [Key]
        public int Id { get; protected set; }
        public string FirstName {get;set;}
        public string LastName {get;set;}
        public string Email {get;set;}
        public string Username { get; set; }
       // public string Gender { get; set; }
        //public Location Location { get; set; }
        //public List<User> Friends{get;set;}
        public int CredentialId { get; set; } // public virtual Credential Credentials { get; protected set; }
        public virtual ICollection<Genre> Interests { get; set; }
        public virtual ICollection<Book> BookFollowed { get; set; }
        public string Image { get; protected set; }
        public IEnumerable<Role> Roles { get; protected set; }
        //joineddate
           // inbox?

           // chapters followed
        

        public string GetRoles()
        {
            return string.Join(",", Roles.Select(c => c.RoleName));
        }

        public virtual void UpdateCredentials(Credential credential, string email)
        {
           // if (credential == null || credential.Hash == null || credential.Salt == null)
          //  {
           //     throw new Exception("Cannot have null or insecure credentials");
           // }
            Email = email;
            CredentialId = credential.Id;
        }

        
    }
}
